package nccloud.riart.pub.utils;

import java.io.FileInputStream;
import java.util.Properties;

import nc.bs.framework.common.RuntimeEnv;

/**
 * OA接口地址获取类
 * 
 * @author Lenovo
 *
 */
public class OAUrlUtils {

	public static final String REQUEST_BATCH_RECEIVE_FLAG = "batchReceiveUrl";
	public static final String REQUEST_DONE_FLAG = "requestDoneUrl";
	public static final String DELETE_RECEIVE_FLAG = "deleteReceiveUrl";

	/**
	 * 获取OA的URL信息
	 * @param urlFlag
	 * @return
	 */
	public static String initUrl(String urlFlag) {
		String homePath = RuntimeEnv.getInstance().getNCHome();
		String oaPath = null;
		homePath = homePath.replace("\\", "/");
		if (!homePath.endsWith("/")) {
			homePath += "/";
		}
		oaPath = homePath + "resources/dayuoa.properties";
		Properties oaProperties = new Properties();
		try {
			oaProperties.load(new FileInputStream(oaPath));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "http://" + oaProperties.get("ip") + ":" + oaProperties.get("port") + oaProperties.getProperty(urlFlag);
	}
	
	/**
	 * 获取NCC的url信息
	 * @return
	 */
	public static Properties getNccUrlInfo() {
		String homePath = RuntimeEnv.getInstance().getNCHome();
		String oaPath = null;
		homePath = homePath.replace("\\", "/");
		if (!homePath.endsWith("/")) {
			homePath += "/";
		}
		oaPath = homePath + "resources/sso.properties";
		Properties oaProperties = new Properties();
		try {
			oaProperties.load(new FileInputStream(oaPath));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return oaProperties;
	}
	
	/**
	 * 获取NCC的url信息
	 * @return
	 */
	public static Properties getWXUrlInfo() {
		String homePath = RuntimeEnv.getInstance().getNCHome();
		String oaPath = null;
		homePath = homePath.replace("\\", "/");
		if (!homePath.endsWith("/")) {
			homePath += "/";
		}
		oaPath = homePath + "resources/dayuoa.properties";
		Properties oaProperties = new Properties();
		try {
			oaProperties.load(new FileInputStream(oaPath));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return oaProperties;
	}
}
